package com.example.account.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.AsyncConfigurer;

import java.util.concurrent.Executor;

/**
 * Author:汪彬彬
 * date:2024/11/20 9:31
 */
@Configuration
public class AsyncConfig implements AsyncConfigurer {


    @Override
    public Executor getAsyncExecutor() {
        CustomThreadPoolExecutor executor = new CustomThreadPoolExecutor();
        // 核心线程数
        executor.setCorePoolSize(5);
        // 最大线程数
        executor.setMaxPoolSize(20);
        // 队列大小
        executor.setQueueCapacity(100);
        // 线程前缀名
        executor.setThreadNamePrefix("ImageProcessor-");
        // 初始化线程池
        executor.initialize();
        return executor;
    }



}
